// https://nuxt.com/docs/api/configuration/nuxt-config
import config from './src/utils/config';

export default defineNuxtConfig({
  /** 运行时环境变量, 可以使用环境变量重写
   * const runtimeConfig = useRuntimeConfig()
   * https://nuxt.com/docs/getting-started/configuration
   */
  runtimeConfig: {
    app: {
      baseURL: "/",
      buildAssetsDir: "/_nuxt",
      cdnURL: "",
    },
    public: {
      /** 个人使用的变量放这里 */
      version: "1.0.4",
    },
  },
  srcDir: "src/",
  vite: {
    css: {
      preprocessorOptions: {
        scss: {
          /** 引入公共scss变量, 只引入变量即可 */
          additionalData: '@import "@/style/common.svar.scss";',
        },
      },
    },
  },
  /** 自定义头部, 全局meta */
  app: {
    head: {
      charset: "utf-8",
      viewport: "width=device-width, initial-scale=1",
      bodyAttrs: {
        // class: '-light'
      },
    },
    /** 切换过快会报错 */
    // pageTransition: { name: "page", mode: "out-in" },
  },
  modules: ["@nuxt/content", "@element-plus/nuxt"],
  typescript: {
    /**
     * disable generating the shim for *.vue files
     * https://nuxt.com/docs/getting-started/installation
     */
    shim: false,
    strict: true,
  },
  /**
   * 路由规则
   * https://nuxt.com/docs/guide/concepts/rendering
   */
  routeRules: {
    // "/admin": {
    //   redirect: { to: "/login", statusCode: 302 },
    // },
    /** 路由组件不做路径映射 */
    "/*/components/*": {
      redirect: { to: "/404", statusCode: 302 },
    }
  },
  imports: {
    // autoImport: false, /** 禁用自动导入 */
  },
  // rootDir: "/<rootDir>",
  // alias: {
  //   "~~": "/<rootDir>",
  //   "@@": "/<rootDir>",
  //   "~": "/<rootDir>",
  //   "@": `/<rootDir>`,
  //   assets: "/<rootDir>/assets",
  //   public: "/<rootDir>/public",
  // },
  proxy: {
    "/api": {
      target: config.proxyTargetUrl,
      pathRewrite: {
        "^/api": "/",
      },
    },
  },
  // axios: {
  //   proxy: true,
  // },
});
